package MazeSolver;

import java.awt.Color;

public class Point implements Comparable<Point>{
	private int x;
	private int y;
	private int cost;
	private int estimatedCost;
	private int rgb;
	private Point previous;
	private boolean visited;

	public Point(int x, int y, int rgb) {
		this.x = x;
		this.y = y;
		this.rgb = rgb;
		cost = Integer.MAX_VALUE;
		previous = null;
		visited = false;
	}
	
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
		this.rgb = 0;
		cost = Integer.MAX_VALUE;
		previous = null;
		visited = false;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getCost() {
		return cost;
	}

	public void setCost(int cost) {
		this.cost = cost;
	}
	
	public int getRgb() {
		return rgb;
	}

	public void setRgb(int rgb) {
		this.rgb = rgb;
	}

	public Point getPrevious() {
		return previous;
	}

	public void setPrevious(Point previous) {
		this.previous = previous;
	}

	public boolean isVisited() {
		return visited;
	}

	public void setVisited(boolean visited) {
		this.visited = visited;
	}

	@Override
	public int compareTo(Point p) {
		if(cost + estimatedCost < p.getCost() + p.getEstimatedCost())
			return -1;
		else if(cost + estimatedCost == p.getCost() + p.getEstimatedCost())
			return 0;
		else
			return 1;
	}

	public int getEstimatedCost() {
		return estimatedCost;
	}

	public void setEstimatedCost(int estimatedCost) {
		this.estimatedCost = estimatedCost + cost;
	}

	public boolean isPassable() {
		return rgb != Color.white.getRGB();
	}
}
